Generate minimum-Matomo compatibility checks into plugin test runs - #48
Closed
snake14 wants to merge 4 commits into
Closed
Generate minimum-Matomo compatibility checks into plugin test runs#48snake14 wants to merge 4 commits into
snake14 wants to merge 4 commits into
Conversation
Plugin CI already runs PluginTests against the minimum Matomo declared in plugin.json, but nothing in that suite compiles assets or templates, so a plugin using a core Less mixin or Twig function newer than its declared minimum shipped undetected (PG-5029).
tests:check-direct-dependency-use matches a vendor namespace preceded by a space, and most plugins assert an exact list of the files it finds, so the generated file must not name the template engine that way.
The test framework already derives it from the class namespace, and a plugin whose name matches a vendor prefix (GeoIp2, Monolog) would otherwise land in the direct-dependency grep via the annotation.
Overrides under templates/plugins/<Other>/ are reachable through the plugin's own namespace, so they are compiled rather than skipped.
This was referenced Aug 11, 2026
Contributor
Author
Contributor
Author
|
Closing as this will go into a new repo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Plugin CI already runs
PluginTestsagainst the minimum Matomo a plugin declares inplugin.json, but nothing in that suite compiles stylesheets or templates. A plugin can therefore use a core Less mixin or Twig function that only exists in a newer Matomo, pass every check, and fatal on every page for anyone running an older version. That is what happened in CustomReports (PG-5029): a.inDarkMode({...})block shipped againstrequire.matomo: ">=5.0.0-rc5"while the mixin only landed in Matomo 5.11.0, so the admin UI died with.inDarkMode is undefined in anonymous-file-0.lesson 5.0–5.10.This adds the missing coverage centrally rather than asking every plugin repository to copy a test file in. Before running phpunit, the action writes small integration tests into the plugin checkout from templates in
scripts/php/templates/:GeneratedAssetCompilationTestcompiles the merged stylesheet with the plugin loaded, so a Less mixin or variable that does not exist in the Matomo under test fails here instead of in production.GeneratedTwigCompilationTestcompiles every template the plugin ships, so a core Twig function, filter or tag that does not exist yet fails the same way. Plugins with no templates report a skip.Because these land in
plugins/<Plugin>/tests/Integration/, they run inside the existingminimum_required_matomomatrix leg — no new job and no extra CI minutes. Nothing changes in any plugin repository, and adding further checks later only requires anotherGenerated*.php.tpl, which the generator picks up automatically.A core test file could not do this: the min-version leg checks out an old core tag, so anything added to core today is simply absent exactly where the check is needed.
Scope of effect. The generation step is skipped entirely unless
plugin-nameis set, so Matomo core's own workflows are unaffected — they scope plugin work throughui-test-optionsandphpunit-test-optionsand never passplugin-name. It is also skipped for suites that do not run plugin integration tests, when the plugin has no test directory, and when the newskip-generated-checksinput is set.Verified on real CI, not just locally. Six plugin workflows were pointed at this branch and dispatched: CustomReports, CustomAlerts, Funnels, FormAnalytics, HeatmapSessionRecording and TagManager — chosen for the largest Less and Twig surface. Every one of the ten
minimum_required_matomolegs passed, each reportingTesting against '5.0.0-rc5'and running both generated checks against that core. TagManager's 884-test run reports no skips, so its 17 templates were genuinely compiled rather than skipped. The only red in the sweep was a known-flakyAPITestin HeatmapSessionRecording, on amaximum_supported_matomoleg, unrelated to these checks.That is six of roughly 46 plugins, so a plugin outside the sample could still be sitting on a real incompatibility. That is the check doing its job rather than a regression, and
skip-generated-checksis the escape hatch if one needs to be unblocked while it is fixed.Two details worth knowing when editing the templates:
isPluginLoaded()and fail loudly rather than silently.tests:check-direct-dependency-usegreps plugin files for a vendor namespace preceded by a space, and most plugins assert an exact list of the files it matches. Generated code must never name a vendor namespace that way. The first pilot run failed on exactly this, and the templates now document the constraint.Related: PG-5221.
Checklist
Review